import { HmacMD5 } from "crypto-js";

export class Tools{
    public static get timestamp(){
        return parseInt(new Date().getTime()/1000+'');
    }
    public static md5(value):string{
        return HmacMD5(value,'1234567890abcdefghijklmnopqrstuvwxyz').toString();
    }
        /**
 * 深拷贝一个对象
 * clone an object
 */
    public static clone(origin):any {
        if (!origin) {
            return;
        }
        let obj = Array.isArray(origin) == true?[]:{};
        for (let f in origin) {
            if (origin.hasOwnProperty(f)) {
                if(typeof(origin[f]) === 'object' && origin[f] != null && origin[f] != undefined){
                    obj[f] = this.clone(origin[f]);
                }else{
                    let v = origin[f];
                    if(v === 'undefined' || v === null || v === 'null' || v === undefined){
                        v = "";
                    }
                    obj[f] = v;
                }
            }
        }
        return obj;
    };
}